package com.demoo.zjsu.util.smartwebsite;

import org.apache.log4j.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.net.URL;

/**
 * Created by jshjsh on 2016/8/15.
 */
public class WebsiteUtil {

    static Logger logger = Logger.getLogger(WebsiteUtil.class);

    public static Document getDocByURL(String url){
        Document document = null;
        try {
             document = Jsoup.parse(new URL(url).openStream(), "GBK", url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return document;
    }


    public static Elements select(Elements elements, String... strings) {
        for (String string: strings) {
            elements = elements.select(string);
        }
        return elements;
    }


}
